package cn.edu.neusoft.wuguangsheng.flowerimpression.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {
    protected  int layout_file=0;
    View view=null;
    abstract void initView();
    abstract void initEvent();
    abstract void initDate();
    public int getLayout_file() {
        return layout_file;
    }

    public void setLayout_file(int layout_file) {
        this.layout_file = layout_file;
    }

    public BaseFragment() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view=inflater.inflate(getLayout_file(),container
                ,false);
        initView();
        initEvent();
        initDate();
        return  view;
    }

    public void clearPass(){
        SharedPreferences sp;
        SharedPreferences.Editor editor;
        sp=getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        editor=sp.edit();
        editor.remove("password");
        editor.remove("userid");
        //editor.remove("password");
        editor.commit();
    }

    public String getuser(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("username","");
    }
    public String getpass(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("password","");
    }
    public String getid(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userid","");
    }
}
